package com.leetcode.LC;

public class LC121 {
    public int maxProfit(int[] prices) {

        int max = 0, min = prices[0];
        for (int i = 0; i < prices.length; i++) {
            if (prices[i] < min) {
                min = prices[i];
            } else if (prices[i] - min > max) {
                max = prices[i] - min;
            }
        }
        return max;
    }

    public static void main(String[] args) {
        System.out.println(new LC121().maxProfit(new int[]{7, 6, 5, 4, 3, 2, 1}));

    }
}
